package com.interceptor.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.interceptor.component.Interceptor1;
import com.interceptor.component.Interceptor2;

/**
 * @Description 拦截器配置
 *
 * @author 堆堆堆
 * @date 2018年4月17日 下午5:53:14
 */
@Configuration
public class WebMvcConfg implements WebMvcConfigurer {

	/**
	 * 添加拦截器链
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {

		// 多个拦截器组成一个拦截器链，addPathPatterns 用于添加拦截规则，excludePathPatterns 用户排除拦截
		registry.addInterceptor(new Interceptor1()).addPathPatterns("/**");
		registry.addInterceptor(new Interceptor2()).addPathPatterns("/**");

	}
}
